package com.gw.detail.controllor.detail;

import com.gw.detail.domain.Reko;
import com.gw.detail.service.IRekoService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 单个事件的重建数据Controller
 *
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/reko")
public class RekoController extends BaseController {
    @Autowired
    private IRekoService rekoService;

    /**
     * 查询单个事件的重建数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:reko:list')")
    @GetMapping("/list")
    public TableDataInfo list(Reko reko) {
        startPage();
        List<Reko> list = rekoService.selectRekoList(reko);
        return getDataTable(list);
    }

    /**
     * 导出单个事件的重建数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:reko:export')")
    @Log(title = "单个事件的重建数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Reko reko) {
        List<Reko> list = rekoService.selectRekoList(reko);
        ExcelUtil<Reko> util = new ExcelUtil<Reko>(Reko.class);
        return util.exportExcel(list, "单个事件的重建数据数据");
    }

    /**
     * 获取单个事件的重建数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:reko:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(rekoService.selectRekoById(id));
    }

    /**
     * 新增单个事件的重建数据
     */
    @PreAuthorize("@ss.hasPermi('detail:reko:add')")
    @Log(title = "单个事件的重建数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Reko reko) {
        return toAjax(rekoService.insertReko(reko));
    }

    /**
     * 修改单个事件的重建数据
     */
    @PreAuthorize("@ss.hasPermi('detail:reko:edit')")
    @Log(title = "单个事件的重建数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Reko reko) {
        return toAjax(rekoService.updateReko(reko));
    }

    /**
     * 删除单个事件的重建数据
     */
    @PreAuthorize("@ss.hasPermi('detail:reko:remove')")
    @Log(title = "单个事件的重建数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(rekoService.deleteRekoByIds(ids));
    }
}
